package com.wyj.util;

/**
 * @author 王永杰
 * @Description
 * @since 2022/7/26
 */
public class RedisKeyUtil {

    private static final String SPLIT = ":";
    private static final String PREFIX_ENTITY_LIKE = "like:entity";
    private static final String PREFIX_USER_LIKE = "like:user";
    private static final String PREFIX_FOLLOWEE = "followee";//关注
    private static final String PREFIX_FOLLOWER = "follower";//粉丝
    private static final String PREFIX_TICKET = "ticker";//登录凭证
    private static final String PREFIX_USER = "user";//
    private static final String PREFIX_UV = "uv";//统计访问网站的访客
    private static final String PREFIX_DAU = "dau";//统计日活跃用户
    private static final String PREFIX_Post = "post";;//记录某个帖子的id


    //key:value
    //like:entity:entityType:entityId --> set(userId)
    public static String getEntityLikeKey(int entityType, int entityId) {
        return PREFIX_ENTITY_LIKE + SPLIT + entityType + SPLIT + entityId;
    }

    //统计每个用户收到的点赞的数量
    public static String getUserLikeKey(int userId) {
        return PREFIX_USER_LIKE + SPLIT + userId;
    }

    //某个用户关注的实体(用户的关注列表多了一个人)
    //followee:userId:entityType --> zset(entityId,now);
    public static String getFolloweeKey(int userId, int entityType) {
        return PREFIX_FOLLOWEE + SPLIT + userId + SPLIT + entityType;
    }

    //某个实体的粉丝
    //follower:entityType:entityId ---> zset(userId,now)
    public static String getFollowerKey(int entityType, int entityId) {
        return PREFIX_FOLLOWER + entityType + SPLIT + entityId;
    }

    //登录凭证
    public static String getLoginTicket(String ticket) {
        return PREFIX_TICKET + SPLIT + ticket;
    }

    /**
    * @Description 缓存用户的信息  一个 user  因为这些东西访问频繁
    * @param
    * @retuen
    * @author wyj
    * @since  2022/7/30 12:26
    */
    public static String getUser(int userId) {
        return PREFIX_USER + SPLIT + userId;
    }


    /**
    * @Description 单日的访客
    * @param
    * @retuen
    * @author wyj
    * @since  2022/8/10 21:41
    */
    public static String getUVKey(String date) {
        return PREFIX_UV + SPLIT + date;
    }


    /**
    * @Description 一段时间的访客
    * @param
    * @retuen
    * @author wyj
    * @since  2022/8/10 21:42
    */
    public static String getUVKey(String startDate,String endDate) {
        return PREFIX_UV + SPLIT +startDate + SPLIT + endDate;
    }

    /**
    * @Description 单日的活跃用户  访问过网站一次就认为其为活跃  那么的话 就在 bitmap 中 设为 true
    * @param
    * @retuen
    * @author wyj
    * @since  2022/8/10 21:42
    */
    public static String getDAUKey(String date) {
        return PREFIX_DAU + SPLIT + date;
    }

    /**
    * @Description 某个区间内的活跃用户
    * @param
    * @retuen
    * @author wyj
    * @since  2022/8/10 21:46

    */
    public static String getDAUKey(String startDate,String endDate) {
        return PREFIX_DAU + SPLIT + startDate + SPLIT + endDate;
    }

    /**
    * @Description 记录某个给帖子的id;
    * @param
    * @retuen java.lang.String
    * @author wyj
    * @since  2022/8/12 15:43

    */
    public static String getPostScore() {
        return PREFIX_Post + SPLIT + "score";
    }


}
